How to Use Imagemaps in your Pages
What is an imagemap? You should know that you can link to another page from an image, but did you know that you can subdivide an image to link to a number of pages depending on where you click? Clicking on different areas on the image sends the user to different parts of your web site. There are two ways of creating imagemaps, server - side or client - side. For the purpose of this tutorial we will concentrate on client-side imagemaps. In order to use imagemaps on your pages you will need the following things: an image that you want to use on your page and the map information in your HTML. |
So What Commands Are Involved?
|
|
Creating your Imagemaps
To create an imagemap look at the picture you have decided to use and in your mind
decide where you would like someone to click and write down what page it would link to,
as shown below
Imagemap 1 will goto page img1.html
You will then need to jot down the co-ordinates of the area of each section. You can use 'rect', 'poly' or 'circle'.
The tag COORDS gives the exact pixel coordinates for the image region. For
'rect' give the x,y coordinates of the top left corner, followed by the coordinates of the bottom
right corner. If you are using 'circles' you will need to give the x, y centre point, followed
by the radius in pixels. For polygons, list the x,y coordinates of all the corners, in a clockwise motion
starting from any point.
Imagemap 1 - rectangle from 0, 0, 400, 80
|
|
Imagemaps.... an example Now that you have all the coordinates you are ready to begin. After the BODY tag in your HTML put the following in: <MAP NAME="mapexamp"> This defines that you are about to set up some information in our case coordinates which can be called up at any time by calling the 'mapexamp' information. After the <MAP NAME> tag you will need to add an <AREA> tag for each region of the image you have drawn. In our examples we have four regions, Imagemaps 1 to 4. So your code should look like something below...
<BODY> Please ensure that you have the </MAP> tag in when you finish defining the regions. |
|
Linking an Image to a Map Then to place the imagemap on your page you simply insert the gif file you are using as normal with the <IMG> tag and add a USEMAP tag so the source should read. <IMG SRC="imagemap.gif" USEMAP="#mapexamp"> With the inclusion of this into your html you should have your imagemap working fine on your web page !!!! So the full code would look like
<HTML><HEAD><TITLE> Imagemap Example</TITLE></HEAD>
The result is as follows: Here is the finished example We will be looking into 'Circles' and 'Polygons' at a later stage. If you would rather use a program to create your imagemaps automatically you can use a program for PC's called MapEdit which is availiable to download from lots of software download sites.
For more information please email [email protected] |